﻿using EasyLoger.Configuration;
using System;
using System.Data.SqlClient;
using System.Xml;
namespace EasyLoger
{
    internal class MSSQLLoger : ILoger
    {
        private MSSQLLogConfig config;
        public MSSQLLoger(XmlNode node)
        {
            this.config = new MSSQLLogConfig(node);
        }
        public void Write(LogMessage msg)
        {
            string sql = "INSERT INTO [dbo].[SysLog]([Msg],[AddDate]) VALUES (@Msg,@AddDate)";
            SqlParameter[] prams = new SqlParameter[]
			{
				new SqlParameter("@Msg", msg.Message),
				new SqlParameter("@AddDate", msg.Date)
			};
            DataBase.RunSql(this.config.Connstr, sql, prams);
        }
        public void Stop()
        {
        }
    }
}
